package cn.tedu._06article.base.interseptor;

import cn.tedu._06article.pojo.vo.loginvo;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;

public class logcheck implements HandlerInterceptor
{
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        loginvo vo= (loginvo) session.getAttribute("user");
        if (vo==null)
        {
//            throw new RuntimeException("请先登录");

            response.sendRedirect("v1/user/login");
            return false;
        }
        return true;
    }
}
